local yinchang = fk.CreateSkill {
  name = "cf_yinchang"
}

Fk:loadTranslationTable {
  ["cf_yinchang"] = "吟唱",
  [":cf_yinchang"] = "出牌阶段，你可以弃置一张牌并选择一名本阶段未以此法选择过的角色，然后选择一项，1.令其增加一点体力上限并回复一点体力，2.令其减少一点体力上限并恢复两点体力(目标体力已损失大于一时可选择此项)。3.令其增加两点体力上限。然后若该角色为你，则你摸三张牌。",
  ["#cf_yinchang"] = "弃置一张牌并选择一名本阶段未选择过的角色",
  ["cf_yinchang_choice1"] = "令其增加一点体力上限并回复一点体力",
  ["cf_yinchang_choice2"] = "令其减少一点体力上限并恢复两点体力",
  ["cf_yinchang_choice3"] = "令其增加两点体力上限",
  ["$cf_yinchang1"] = "我会保护大家。",
  ["$cf_yinchang2"] = "吟唱，开始！",
}

yinchang:addEffect('active', {
  anim_type = "support",
  prompt = "#" .. yinchang.name,
  can_use = function(self, player)
    return player:hasSkill(self.name)
  end,
  card_num = 1,
  card_filter = function(self, player, to_select, selected, selected_targets)
    return table.contains(player:getCardIds("he"), to_select)
  end,
  target_num = 1,
  target_filter = function(self, player, to_select, selected, selected_cards, card, extra_data)
    return #selected == 0 and not table.contains(player:getTableMark(self.name .. "-phase"), to_select.id)
  end,
  on_use = function(self, room, skillUseEvent)
    local player = skillUseEvent.from
    local target = skillUseEvent.tos[1]
    room:throwCard(skillUseEvent.cards, self.name, player)
    local choice
    if target:getLostHp() > 1 then
      choice = room:askToChoice(player, {
        choices = { self.name .. "_choice1", self.name .. "_choice2", self.name .. "_choice3" },
        skill_name = self.name
      })
    else
      choice = room:askToChoice(player, {
        choices = { self.name .. "_choice1", self.name .. "_choice3" },
        skill_name = self.name
      })
    end
    if choice == self.name .. "_choice1" then
      room:changeMaxHp(target, 1)
      room:recover {
        who = target,
        skillName = self.name,
        num = 1
      }
    elseif choice == self.name .. "_choice2" then
      room:changeMaxHp(target, -1)
      room:recover {
        who = target,
        skillName = self.name,
        num = 2
      }
    elseif choice == self.name .. "_choice3" then
      room:changeMaxHp(target, 2)
    end
    room:addTableMark(player, self.name .. "-phase", target.id)
    room:addTableMark(player, self.name, target.id)
    if target == player then
      player:drawCards(3, self.name)
    end
  end
})

return yinchang
